import requests
import json
import zipfile
import os

# 获取当前工作目录的路径
path = os.getcwd()
print(path,"999")

# 获取书籍ID列表
def getBooksId():
    # 请求获取书籍信息的URL
    url = "https://www.zhipin.com/wapi/zpgeek/recommend/job/list.json?expectId=b10e8ddfd626f90e0Hx92t29GVpV&pk=cpc_job_index_hangzhou&sortType=1&page=1&salary=&payType=&degree=&experience=&stage=&scale=&districtCode=&businessCode="
    # # 解析返回的JSON数据，提取书籍列表
    headers = {
       'Cookie':'ab_guid=0d713249-ed49-4fb0-b8fe-4aa28934fc24; lastCity=101210100; sid=sem_pz_bdpc_dasou_title; __g=sem_pz_bdpc_dasou_title; Hm_lvt_194df3105ad7148dcf2b98a91b5e727a=1748500507,1748937780,1749543427,1750756582; HMACCOUNT=A8C1EDA16EDC7013; wt2=D6BERk_si44URiLI8eNx6p6NgqQzZOMHonOgCLwv5HNdZDGEdP9KWHMI0KuwocpJ4naWUEau4iPg5bgAn-ZkxxQ~~; wbg=0; zp_at=N9qhVxYKmtf3zJFvFpN_7pxtH2rxh_EvvNMHDamLDuw~; __l=r=https%3A%2F%2Fwww.zhipin.com%2F%3Fsid%3Dsem_pz_bdpc_dasou_title&l=%2Fcitysite%2Fhangzhou%2F%3Fsid%3Dsem_pz_bdpc_dasou_title%26seoRefer%3Dindex&s=1; __zp_stoken__=c66ffw5Vnwq4SO2ITHWAdaWt%2Fw4Nzw4F8wrlbS1Z1fU5kTlhawrtWcMOBbcKvYlXDhVRVwovCt8KswrzCpMKaw4%2FDjMO%2BS8O1wqnCkcKmwqXEmcO1wqvFs8WCwrDDh8KmRDMODgoUCw4OChQLHBwLCQoJCRUXCBISFhAfODDDhiE7OUI7K11cXAlfYmZXYksUWFROOT4JHAtgPj1ROzk6w43Ct8OEwpnDjMK3wrs9w4PCqsK7MTtBOkfCuTIqN8K%2Bw5YfFw7CvmAXfw7CviUXw4lic8Ojw7fDhMWHMzk6wr5PPiVBRDtMPjpBOz41RcK5w5zDl29%2Fw63DrsK5Rio5G0Y%2BOk85Pj46TTtMKjpMHDQ%2BOylPCRIUFBwpTcOHwqTCusOgPjo%3D; __zp_seo_uuid__=63df730a-6cfe-43d1-9f22-b6dc188a1a77; __c=1750756581; __a=76538719.1744166247.1749543426.1750756581.163.7.8.8;'
    }
    bookList = json.loads(requests.get(url,headers=headers).text)['zpData']['jobList']
    # print(bookList, "bookList")
    BooksId = []
    # 遍历书籍列表，提取每本书的ID
    for item in bookList:
        BooksId.append(item["brandScaleName"])
    return BooksId

def main():
    # 获取书籍ID列表
    BooksId = getBooksId()
    print(BooksId,"888888")

    # print(BooksId)
    # # 获取书籍下载链接
    # downlink = getBooksDownLink(BooksId)
    # print(downlink)
    #
    # # 下载每本书并解压
    # for book in downlink:
    #     downBook(book["title"], book["link"])

# 程序入口
if __name__ == '__main__':
    main()